<?php
class XSocial {
    public $platform;
    public $appIframeUrl;
    public $platParams;
    public $secretKey;
    public $webRoot;
    public $canvasPath;
    public $mode;
    
    const JS = 'js';
    const SERVER = 'server';
    
    const TEST = 'test';
    const FACEBOOK = 'facebook';
    const RENREN = 'renren';
    const ORKUT = 'orkut';
    const NATE = 'nate';
    
    private $cacheHandler;
    const CACHE_FILE = 'cache_file';
    const CACHE_SESSION = 'cache_session';
    const CACHE_MEMCACHE = 'cache_memcache';
    
    public function __construct() {
        $this->platform = XSocial::TEST;
        $this->webRoot = "";
        $this->secretKey = "";
        $this->canvasPath = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
        
        $this->mode = XSocial::JS;
    }
    
    public function service() {
        $action = $_REQUEST['action'];
        if (empty($action)) $action = 'template';
        include 'template/' . $this->platform . '/' . $action . '.php';
    }
    
    public function action($action) {
        if (strpos($this->canvasPath,'?') === false) {
            $connector = '?';
        } else {
            $connector = '&';
        }
        
        return $this->canvasPath . $connector . 'action=' . $action;
    }
    
    public function setCache($handler) {
        
    }
}